<template>
  <div class="c-ph24 c-pt40 c-pb30 c-bd-b1" v-if="themeName == 'mb5' && !isMicroPage">
    <div class="c-flex-row c-aligni-center">
      <span class="c-fs30">{{wordName}}</span>
      <span class="c-fs18 c-fc-sgray c-pt4 c-ml16 c-w0 c-flex-grow1 c-mr16 c-text-ellipsis1">{{wordDesc}}</span>
      <span class="c-fs20 c-fc-gray" @click="clickMoreWord">更多</span>
    </div>
    <div @click="clickGoWordDetail(item.dId)" class=" c-pt30 c-flex-row" :key="index" v-for="(item,index) in wordList">
      <div class="c-ww240 c-maxh160 c-text-hidden c-p">
        <img class="c-w100 imgCloseBig" :src="$addXossFilter(item.poster, require('../../assets/defult270.png'))" />
      </div>
      <div class="c-pl20 c-w0 c-flex-grow1 c-flex-column c-justify-sb">
        <div class="c-fs24 c-text-ellipsis2 c-lh36">{{item.name}}</div>
        <div class="c-flex-row c-aligni-center c-pb10">
          <div class="c-fs18 c-fc-gray c-lh c-flex-grow1 c-w0">{{item.count}}人使用</div>
          <div class="theme-fc c-flex-row c-aligni-end">
            <span :class="Number(item.price) == 0 ? 'c-fs22' : 'c-fs24'"><span v-if="Number(item.price) != 0">{{'￥' | iosPriceFilter}}</span>{{item.price | moneyStr}}</span>
          </div>
        </div>
      </div>
    </div>
  </div>
  <div class="c-ph24 c-bd-b12-f5" v-else-if="themeName == 'mb4' && !isMicroPage">
    <div class="c-pt40 c-flex-row c-aligni-center">
      <span class="c-fs30 c-p c-lh c-pl20"><span class="c-pa theme-bd-l2 theme-bd-r2 c-h c-p-l0 c-br8 c-w0"></span>{{wordName}}</span>
      <span class="c-fs18 c-fc-sgray c-pt4 c-ml16 c-w0 c-flex-grow1 c-mr16 c-text-ellipsis1">{{wordDesc}}</span>
      <span class="c-fs20 c-fc-gray c-pl8" @click="clickMoreWord">查看更多</span>
    </div>
    <div>
      <div v-for="(item,index) in wordList" :key="index" class=" c-pt24 c-flex-row" @click="clickGoWordDetail(item.dId)">
        <div class="c-pb24">
          <div class="c-ww210 c-maxh210 c-br10 c-text-hidden c-p">
            <img class="c-w100 imgCloseBig c-br10" :src="$addXossFilter(item.poster, require('../../assets/defult270.png'))" />
          </div>
        </div>
        <div class="c-ml20 c-w0 c-flex-grow1 c-flex-column c-justify-sb c-pb24" :class="index == wordList.length - 1 ? '' : 'c-bd-b1'">
          <div class="c-fs24 c-text-ellipsis2 c-lh32">{{item.name}}</div>
          <div class="c-flex-row c-flex-center">
            <div class="c-lh c-fs30 c-flex-row theme-fc c-flex-grow1 c-w0">
              <span :class="Number(item.price) == 0 ? 'c-fs22' : 'c-fs24'"><span v-if="Number(item.price) != 0">{{'￥' | iosPriceFilter}}</span>{{item.price | moneyStr}}</span>
            </div>
            <div class="c-lh c-fs18 c-fc-gray">{{item.count}}人使用</div>
          </div>
        </div>
      </div>
    </div>
  </div>

  <div v-else-if="themeName == 'mb3' && !isMicroPage">
    <index-three-title-com :titleName="wordName" :titleDesc="wordDesc" @clickMore="clickMoreWord"></index-three-title-com>
    <div class="c-ph24 c-pb20 c-bd-b12-f5">
      <div @click="clickGoWordDetail(item.dId)" class="c-pt24 c-flex-row" :key="index" v-for="(item,index) in wordList">
        <div class="c-pb24">
          <div class="c-ww210 c-maxh210 c-text-hidden c-p c-br10">
            <img class="c-w100 imgCloseBig c-br10" :src="$addXossFilter(item.poster, require('../../assets/defult270.png'))" />
          </div>
        </div>
        <div class="c-ml20 c-w0 c-flex-grow1 c-flex-column c-justify-sb c-pb24" :class="index == wordList.length - 1 ? '' : 'c-bd-b1'">
          <div class="c-fs24 c-text-ellipsis2 c-lh36 ">{{item.name}}</div>
          <div class="c-flex-row  c-justify-sb c-flex-center">
            <div class="c-flex-row theme-fc c-flex-grow1 c-w0">
              <span v-if="item.price * 1 > 0" class="c-fs24">{{'￥' | iosPriceFilter}}</span>
              <span :class="item.price * 1 > 0 ? 'c-fs24' : 'c-fs22'">{{item.price | moneyStr}}</span>
            </div>
            <div class=" c-fs18 c-fc-gray">{{item.count}}人使用</div>
          </div>
        </div>
      </div>
    </div>

  </div>

  <div class="c-ph24 c-pt24 c-pb40 c-mt12 c-bg-white" v-else-if="themeName == 'mb6' && !isMicroPage">
    <div class="c-flex-row c-aligni-end c-mb10">
      <span class="c-fs28 c-fw-b">{{wordName}}</span>
      <span class="c-fs20 c-fc-gray c-mb2 c-ml16 c-w0 c-flex-grow1 c-mr16 c-text-ellipsis1">{{wordDesc}}</span>
      <span class="c-fs18 c-fc-gray" @click="clickMoreWord">更多</span>
    </div>
    <div @click="clickGoWordDetail(item.dId)" class="c-pt24 c-flex-row " :key="index" v-for="(item,index) in wordList">
      <div class="c-ww160 c-maxh106 c-text-hidden c-p">
        <img class="c-w100 imgCloseBig c-h c-br6" :src="$addXossFilter(item.poster, require('../../assets/defult270.png'))" />
      </div>
      <div class="c-pl20 c-w0 c-flex-grow1 c-flex-column" :class="index == wordList.length - 1 ? '' : 'c-pb24 c-bd-b1'">
        <div class="c-fs24 c-text-ellipsis2 c-lh36 c-fw-b c-hh72">{{item.name}}</div>
        <div class="c-flex-row c-justify-sb c-aligni-end">
          <div class="c-fs18 c-fc-gray c-flex-grow1 c-w0">{{item.count}}人使用</div>
          <span class="theme-fc c-flex-grow1 c-textAlign-r" :class="Number(item.price) == 0 ? 'c-fs22' : 'c-fs24'"><span v-if="Number(item.price) != 0">{{'￥' | iosPriceFilter}}</span>{{item.price | moneyStr}}</span>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import indexThreeTitleCom from "@/components/templates/common/indexThreeTitleCom.vue";
import { utilJs } from "@/utils/common.js"
export default {
  name: "WordIndexCom",
  components: {
    indexThreeTitleCom
  },
  props: {
    wordName: {
      type: String,
      default: '词典',
    },
    wordDesc: {
      type: String,
      default: '词典',
    },
    wordList: {
      type: Array,
      default: () => []
    },
    isFromM7: {
      type: Boolean,
      default: false
    },
    itemType: {
      type: Number,
      default: 1, //1一行一列，2一行两列，3一行三列
    },
    showCount: {
      type: Number,
      default: 1
    },
    isMicroPage: {
      type: Boolean,
      default: false
    },
    showMore: {
      type: Number,
      default: 0,
    },
    visible:{
      type: Object,
      default: () => {
        return {
          priceVisible:true, // 价格、商品价格
          originalPriceVisible:true, // 划线价格
          dataVisible:true, // 商品数据、数据字段、数据
          statusVisible:true, // 状态
          forecastVisible:true, // 预告时间
          qrVisible:true, // 预告二维码
          vipVisible:true, // vip角标
        }
      },
    }
  },
  data() {
    return {
      theme: localStorage.getItem("colorName")
        ? localStorage.getItem("colorName")
        : "mb5_default",
      themeName: localStorage.getItem("themeName")
        ? localStorage.getItem("themeName")
        : "mb5"
    };
  },
  methods: {
    iosAppRouteChange(toPath) {
      if (utilJs.isIOSApp()) {
        window.webkit.messageHandlers.iosWechatRoute.postMessage(toPath);
      } else if (utilJs.isAndoridNewApp()) {
        let data = {
          path: toPath
        }
        window.androidWechatRoute.doAction(JSON.stringify(data))
      } else {
        this.$routerGo(this, "push", { path: toPath });
      }
    },
    clickMore() {
      this.$emit("clickMore");
    },
    clickMoreWord() {
      let toPath = `/homePage/word/wordList`;
      this.iosAppRouteChange(toPath);
    },
    clickGoWordDetail(dId) {
      let toPath = `/homePage/word/wordDetail?dId=${dId}`;
      this.iosAppRouteChange(toPath);
    }
  }
};
</script>

<style scoped>
.mb4_default .theme-bd-r2 {
  border-right: 2px solid #ff300c;
}
</style>
